
from socket import *
ADDR = ("0.0.0.0",8888)

tcp = socket(AF_INET,SOCK_STREAM)
tcp.bind(ADDR)

tcp.listen(5)

tcp.setblocking(False)
client_list = []

while True:

    try:

        conn,addr = tcp.accept()
        client_list.append(conn)
    except BlockingIOError:
        remove_list = []
        for sock in client_list:
            try:
                data = sock.recv(1024)
                print(data.decode())
                print("谢谢")

                sock.send(data)
            except BlockingIOError:
                continue

            except Exception:
                sock.close()
                remove_list.append(sock)
        for i in remove_list:
            client_list.remove(i)

conn.close()
tcp.close()